//#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int n;	cin >> n;
	vector<int>nums;
	for (int i = 0; i < n; i++) {
		int x;	 cin >> x;
		nums.push_back(x);
	}	
	vector<int>dp;
	dp.push_back(nums[0]);
	int max_num = nums[0];
	for (int i = 1; i < n; i++) {
		dp.push_back(0);
		dp[i] = max(dp[i - 1] + nums[i], nums[i]);
		if (max_num < dp[i])	max_num = dp[i];
	}
	cout << max_num;
	cout << sizeof(int);
	return 0;
}